/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package javalens.gui;

import javalens.*;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTabbedPane;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

/** I'll turn this into a proper GUI later on, for now let's just get straight to the
 * primary function, which is to generate a data set of derived light curve 
 * features using the event, curve and data set generators
 *
 * @author vermaak
 */
public class Main extends JFrame implements ActionListener {

    private JButton dataSetButton;
    private JLabel nDataCurvesTextLabel;
    private JTextField nDataCurvesTextField;
    private JTabbedPane tabPane = new JTabbedPane();

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        try {
            // Set cross-platform Java L&F (also called "Metal")
            UIManager.setLookAndFeel(
                    UIManager.getSystemLookAndFeelClassName());
        } catch (UnsupportedLookAndFeelException e) {
            // handle exception
        } catch (ClassNotFoundException e) {
            // handle exception
        } catch (InstantiationException e) {
            // handle exception
        } catch (IllegalAccessException e) {
            // handle exception
        }

        System.out.println("JAVALENS - 2008");
        new Main();
    }
    // constructor         

    public Main() {
        //give the window a name                  
        super("The very primitive GUI for javalens");
        setDefaultCloseOperation(EXIT_ON_CLOSE);
//        this.getContentPane().setLayout(new BoxLayout(this.getContentPane(), BoxLayout.Y_AXIS));
        add(tabPane);
        tabPane.addTab("Create a Curve", new CreateCurvePanel());
//        tabPane.addTab("Create a DataSet",new CreateCurvePanel());


        // set up data set generation
//        nDataCurvesTextLabel = new JLabel("Number of random curves");
//        this.getContentPane().add(nDataCurvesTextLabel);
//        nDataCurvesTextField = new JTextField("20",6);
//        this.getContentPane().add(nDataCurvesTextField);
//        dataSetButton = new JButton("Create data set");
//        dataSetButton.addActionListener(this);
//        this.getContentPane().add(dataSetButton);

        //display the window                  
        this.pack();
        this.setVisible(true);
    }

    public void actionPerformed(ActionEvent e) {
        if (e.getSource() == dataSetButton) {
            try {
                int nCurves = Integer.valueOf(nDataCurvesTextField.getText());
                Command createDataSetCommand = new CreateDataSetCommand(nCurves);
                createDataSetCommand.execute();
            } catch (Exception ex) {
                Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }
}
